﻿
'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'
'
'*******************************************************************


Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling

Imports System
Imports System.ComponentModel

Imports System.Data
Imports System.IO
Imports System.Xml
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Type

Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Visio


Imports visRackComponentAttributes.clsVisioSupport
Imports visRackComponentAttributes.clsDC_RackData
Imports visRackComponentAttributes.dc_Network
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Public Class clsAttrNetwork


#Region " properties and definitions "

    Public m_db As Database
    Public m_ds As DataSet
    Public m_dt As DataTable

    Public m_dc As dc_Network
    Public m_oc As Collection(Of dc_Network)

    Private strUserId As String

    Public m_deleteCommand As DbCommand
    Public m_insertCommand As DbCommand
    Public m_updateCommand As DbCommand


    Private _clsVisio As visRackComponentAttributes.clsVisioSupport

    Public Const readAll As String = "selectTblAttrNetwork"

    ' who am I
    Private myEnum As DC_RackTables = DC_RackTables.tblAttrNetwork

    Private m_visshape As Microsoft.Office.Interop.Visio.Shape
    Property _VisShape() As Microsoft.Office.Interop.Visio.Shape
        Get
            Return Me.m_visshape
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Shape)
            m_visshape = value
        End Set
    End Property

    '********* visio snippet vb.net vis0041vb ******************
    Private _drawingApplication As Microsoft.Office.Interop.Visio.Application
    Public Property drawingApplication() As Microsoft.Office.Interop.Visio.Application
        Get
            Return Me._drawingApplication
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Application)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("ApplicationValueIsNull", _
                    "drawingApplication is Null.")
            End If
            Me._drawingApplication = value
        End Set
    End Property

    '********* visio snippet vb.net vis0043vb ******************
    Private _drawingDocument As Microsoft.Office.Interop.Visio.Document
    Public Property drawingDocument() As Microsoft.Office.Interop.Visio.Document
        Get
            Return Me._drawingDocument
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Document)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("DocumentValueIsNull", _
                    "drawingDocument is Null.")
            End If
            Me._drawingDocument = value
        End Set
    End Property

    '********* visio snippet vb.net vis0045vb ******************
    Private _drawingWindow As Microsoft.Office.Interop.Visio.Window
    Public Property drawingWindow() As Microsoft.Office.Interop.Visio.Window
        Get
            Return Me._drawingWindow
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Window)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("WindowValueIsNull", _
                    "drawingWindow is Null.")
            End If
            Me._drawingWindow = value
        End Set
    End Property

    '********* visio snippet vb.net vis0044vb ******************
    Private _drawingPage As Microsoft.Office.Interop.Visio.Page
    Public Property drawingPage() As Microsoft.Office.Interop.Visio.Page
        Get
            Return Me._drawingPage
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Page)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("PageValueIsNull", _
                    "drawingPage is Null.")
            End If
            Me._drawingPage = value
        End Set
    End Property

    Public m_customstencilpath As String = My.Settings.path_custom_stencils
    Public Property _CustomStencilPath() As String
        Get
            Return Me.m_customstencilpath
        End Get
        Set(ByVal value As String)
            Me.m_customstencilpath = value
        End Set
    End Property


#End Region

#Region " Move/Transform Data "

    '
    ' create columns
    '
    Public Sub CreateTableColumns(ByRef tempTable As DataTable)

        Dim newDC As dc_Network = New dc_Network(strUserId)

        Try
            Dim colattrnetKey As New System.Data.DataColumn
            colattrnetKey.ColumnName = "attrnetKey"
            colattrnetKey.DataType = GetType(Integer)
            colattrnetKey.DefaultValue = m_dc.attrnetKey
            tempTable.Columns.Add(colattrnetKey)

            Dim colattrnetPortKey As New System.Data.DataColumn
            colattrnetPortKey.ColumnName = "attrnetPortKey"
            colattrnetPortKey.DataType = GetType(Integer)
            colattrnetPortKey.DefaultValue = m_dc.attrnetPortKey
            tempTable.Columns.Add(colattrnetPortKey)

            Dim colattrnetCompKey As New System.Data.DataColumn
            colattrnetCompKey.ColumnName = "attrnetCompKey"
            colattrnetCompKey.DataType = GetType(Integer)
            colattrnetCompKey.DefaultValue = m_dc.attrnetCompKey
            tempTable.Columns.Add(colattrnetCompKey)

            Dim colattrnetDomainName As New System.Data.DataColumn
            colattrnetDomainName.ColumnName = "attrnetDomainName"
            colattrnetDomainName.DataType = GetType(String)
            colattrnetDomainName.DefaultValue = m_dc.attrnetDomainName
            tempTable.Columns.Add(colattrnetDomainName)

            Dim colattrnetNetworkName As New System.Data.DataColumn
            colattrnetNetworkName.ColumnName = "attrnetNetworkName"
            colattrnetNetworkName.DataType = GetType(String)
            colattrnetNetworkName.DefaultValue = m_dc.attrnetNetworkName
            tempTable.Columns.Add(colattrnetNetworkName)

            Dim colattrnetIpAddress As New System.Data.DataColumn
            colattrnetIpAddress.ColumnName = "attrnetIpAddress"
            colattrnetIpAddress.DataType = GetType(String)
            colattrnetIpAddress.DefaultValue = m_dc.attrnetIpAddress
            tempTable.Columns.Add(colattrnetIpAddress)

            Dim colattrnetSubnetMask As New System.Data.DataColumn
            colattrnetSubnetMask.ColumnName = "attrnetSubnetMask"
            colattrnetSubnetMask.DataType = GetType(String)
            colattrnetSubnetMask.DefaultValue = m_dc.attrnetSubnetMask
            tempTable.Columns.Add(colattrnetSubnetMask)

            Dim colattrnetMacAddress As New System.Data.DataColumn
            colattrnetMacAddress.ColumnName = "attrnetMacAddress"
            colattrnetMacAddress.DataType = GetType(String)
            colattrnetMacAddress.DefaultValue = m_dc.attrnetMacAddress
            tempTable.Columns.Add(colattrnetMacAddress)

            Dim colattrnetWWNID As New System.Data.DataColumn
            colattrnetWWNID.ColumnName = "attrnetWWNID"
            colattrnetWWNID.DataType = GetType(String)
            colattrnetWWNID.DefaultValue = m_dc.attrnetWWNID
            tempTable.Columns.Add(colattrnetWWNID)

            Dim colattrnetStatus As New System.Data.DataColumn
            colattrnetStatus.ColumnName = "attrnetStatus"
            colattrnetStatus.DataType = GetType(Integer)
            colattrnetStatus.DefaultValue = m_dc.attrnetStatus
            tempTable.Columns.Add(colattrnetStatus)

            Dim colattrnetStatusDate As New System.Data.DataColumn
            colattrnetStatusDate.ColumnName = "attrnetStatusDate"
            colattrnetStatusDate.DataType = GetType(Date)
            colattrnetStatusDate.DefaultValue = m_dc.attrnetStatusDate
            tempTable.Columns.Add(colattrnetStatusDate)

            Dim colattrnetComments As New System.Data.DataColumn
            colattrnetComments.ColumnName = "attrnetComments"
            colattrnetComments.DataType = GetType(String)
            colattrnetComments.DefaultValue = m_dc.attrnetComments
            tempTable.Columns.Add(colattrnetComments)

            Dim colattrnetLastEdit As New System.Data.DataColumn
            colattrnetLastEdit.ColumnName = "attrnetLastEdit"
            colattrnetLastEdit.DataType = GetType(String)
            colattrnetLastEdit.DefaultValue = m_dc.attrnetLastEdit
            tempTable.Columns.Add(colattrnetLastEdit)

            Dim colattrnetLastUpdate As New System.Data.DataColumn
            colattrnetLastUpdate.ColumnName = "attrnetLastUpdate"
            colattrnetLastUpdate.DataType = GetType(Date)
            colattrnetLastUpdate.DefaultValue = m_dc.attrnetLastUpdate
            tempTable.Columns.Add(colattrnetLastUpdate)

            newDC = Nothing

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

        If newDC IsNot Nothing Then
            newDC = Nothing
        End If

    End Sub

    '
    ' use for writing records
    '
    Public Sub movePropertiesToDataRow _
            (ByRef tempRow As DataRow, _
             ByVal tempDC As dc_Network)

        Try
            With tempDC
                tempRow.SetField("attrnetKey", .attrnetKey)
                tempRow.SetField("attrnetPortKey", .attrnetPortKey)
                tempRow.SetField("attrnetCompKey", .attrnetCompKey)
                tempRow.SetField("attrnetDomainName", .attrnetDomainName)
                tempRow.SetField("attrnetNetworkName", .attrnetNetworkName)
                tempRow.SetField("attrnetIpAddress", .attrnetIpAddress)
                tempRow.SetField("attrnetSubnetMask", .attrnetSubnetMask)
                tempRow.SetField("attrnetMacAddress", .attrnetMacAddress)
                tempRow.SetField("attrnetWWNID", .attrnetWWNID)
                tempRow.SetField("attrnetStatus", .attrnetStatus)
                tempRow.SetField("attrnetStatusDate", .attrnetStatusDate)
                tempRow.SetField("attrnetComments", .attrnetComments)
                tempRow.SetField("attrnetLastEdit", strUserId)
                tempRow.SetField("attrnetLastUpdate", .attrnetLastUpdate)
            End With


        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub


    '
    ' for reading records
    '
    Public Sub moveDataRowToProperties _
            (ByVal tempRow As DataRow)

        Try

            With m_dc
                .initProperties()
                .attrnetKey = tempRow.Item("attrnetKey")
                .attrnetPortKey = tempRow.Item("attrnetPortKey")
                .attrnetCompKey = tempRow.Item("attrnetCompKey")
                .attrnetDomainName = tempRow.Item("attrnetDomainName")
                .attrnetNetworkName = tempRow.Item("attrnetNetworkName")
                .attrnetIpAddress = tempRow.Item("attrnetIpAddress")
                .attrnetSubnetMask = tempRow.Item("attrnetSubnetMask")
                .attrnetMacAddress = tempRow.Item("attrnetMacAddress")
                .attrnetWWNID = tempRow.Item("attrnetWWNID")
                .attrnetStatus = tempRow.Item("attrnetStatus")
                .attrnetStatusDate = tempRow.Item("attrnetStatusDate")
                .attrnetComments = tempRow.Item("attrnetComments")
                .attrnetLastUpdate = tempRow.Item("attrnetLastUpdate")
                .attrnetLastEdit = tempRow.Item("attrnetLastEdit")
            End With

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub


    '
    ' for reading records
    '
    Public Sub moveDataRowToProperties _
            (ByVal tempRow As DataRow, _
            ByRef tempDC As dc_Network)

        Try

            With tempDC
                .initProperties()
                .attrnetKey = tempRow.Item("attrnetKey")
                .attrnetPortKey = tempRow.Item("attrnetPortKey")
                .attrnetCompKey = tempRow.Item("attrnetCompKey")
                .attrnetDomainName = tempRow.Item("attrnetDomainName")
                .attrnetNetworkName = tempRow.Item("attrnetNetworkName")
                .attrnetIpAddress = tempRow.Item("attrnetIpAddress")
                .attrnetSubnetMask = tempRow.Item("attrnetSubnetMask")
                .attrnetMacAddress = tempRow.Item("attrnetMacAddress")
                .attrnetWWNID = tempRow.Item("attrnetWWNID")
                .attrnetStatus = tempRow.Item("attrnetStatus")
                .attrnetStatusDate = tempRow.Item("attrnetStatusDate")
                .attrnetComments = tempRow.Item("attrnetComments")
                .attrnetLastUpdate = tempRow.Item("attrnetLastUpdate")
                .attrnetLastEdit = tempRow.Item("attrnetLastEdit")
            End With

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Public Sub moveDataTableToObservableCollection _
            (ByVal dtTemp As DataTable)

        Try

            If 0 < dtTemp.Rows.Count Then

                If m_oc IsNot Nothing Then
                    m_oc = Nothing
                    m_oc = New Collection(Of dc_Network)
                Else
                    m_oc = New Collection(Of dc_Network)
                End If

                Dim drTemp As DataRow
                Dim dcTemp As dc_Network
                For Each drTemp In dtTemp.Rows
                    dcTemp = New dc_Network
                    moveDataRowToProperties(drTemp, dcTemp)
                    m_oc.Add(dcTemp)
                Next

            End If

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try



    End Sub

    '
    '
    '
    Public Function moveDataTableToXML() As XmlDocument

        Dim writer = New System.IO.StringWriter
        Dim m_dt_xml As Xml.XmlDocument = Nothing

        Try


            m_dt.WriteXml(writer, XmlWriteMode.WriteSchema, True)
            m_dt_xml = Nothing
            m_dt_xml = New Xml.XmlDocument
            m_dt_xml.LoadXml(writer.ToString)

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        Finally

            writer = Nothing

        End Try

        Return m_dt_xml


    End Function


#End Region

#Region " standard calls "

    '
    '
    '
    Private Sub buildUpdateAttrNetworkCommand()

        Try
            m_updateCommand = m_db.GetStoredProcCommand("updateAttrNetwork")

            Dim cmdActive As DbCommand = m_updateCommand
            m_db.AddInParameter(cmdActive, "attrnetKey", DbType.Int32, "attrnetKey", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetPortKey", DbType.Int32, "attrnetPortKey", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetCompKey", DbType.Int32, "attrnetCompKey", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetDomainName", DbType.String, "attrnetDomainName", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetNetworkName", DbType.String, "attrnetNetworkName", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetIpAddress", DbType.String, "attrnetIpAddress", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetSubnetMask", DbType.String, "attrnetSubnetMask", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetMacAddress", DbType.String, "attrnetMacAddress", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetWWNID", DbType.String, "attrnetWWNID", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetStatus", DbType.Int16, "attrnetStatus", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetStatusDate", DbType.Date, "attrnetStatusDate", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetComments", DbType.String, "attrnetComments", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetLastUpdate", DbType.Date, "attrnetLastUpdate", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetLastEdit", DbType.String, "attrnetLastEdit", DataRowVersion.Current)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Private Sub buildInsertAttrNetworkCommand()

        Try
            m_insertCommand = m_db.GetStoredProcCommand("insertAttrNetwork")

            Dim cmdActive As DbCommand = m_insertCommand
            m_db.AddInParameter(cmdActive, "attrnetPortKey", DbType.Int32, "attrnetPortKey", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetCompKey", DbType.Int32, "attrnetCompKey", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetDomainName", DbType.String, "attrnetDomainName", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetNetworkName", DbType.String, "attrnetNetworkName", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetIpAddress", DbType.String, "attrnetIpAddress", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetSubnetMask", DbType.String, "attrnetSubnetMask", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetMacAddress", DbType.String, "attrnetMacAddress", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetWWNID", DbType.String, "attrnetWWNID", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetStatus", DbType.Int16, "attrnetStatus", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetStatusDate", DbType.Date, "attrnetStatusDate", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetComments", DbType.String, "attrnetComments", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetLastUpdate", DbType.Date, "attrnetLastUpdate", DataRowVersion.Current)
            m_db.AddInParameter(cmdActive, "attrnetLastEdit", DbType.String, "attrnetLastEdit", DataRowVersion.Current)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Private Sub buildDeleteAttrNetworkCommand()

        Try
            m_deleteCommand = m_db.GetStoredProcCommand("deleteAttrNetwork")

            Dim cmdActive As DbCommand = m_deleteCommand
            m_db.AddInParameter(cmdActive, "attrnetKey", DbType.Int32, "attrnetKey", DataRowVersion.Current)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Public Function dbUpdateDataSet() As Int16

        Dim rowsAffected As Int16 = 0

        Try

            rowsAffected = m_db.UpdateDataSet(m_ds, DC_RackTables.tblAttrNetwork.ToString, _
                                        m_insertCommand, _
                                        m_updateCommand, _
                                        m_deleteCommand, _
                                        UpdateBehavior.Standard)
            'msgbox rowsAffected

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If

        End Try

        Return rowsAffected

    End Function

    '
    ' create a record based on property values move it to the generic datatable
    ' then copy the table to the database
    '
    Public Function addAttrNetworkDataSourceRecord _
        (ByVal tempDc As dc_Network, _
         Optional ByVal blnSilent As Boolean = False) _
        As Integer

        Dim intRowsAffected As Integer = 0

        Try

            initDataSetAndTable()

            Dim m_dr As DataRow = m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString).NewRow
            movePropertiesToDataRow(m_dr, tempDc)
            m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString).Rows.Add(m_dr)
            intRowsAffected = dbUpdateDataSet()

            ' if the command completes successfully and a shape has
            ' been passed, go update the network properties in the shape
            If intRowsAffected = 1 And (Not (_VisShape Is Nothing)) Then
                UpdateNetworkProperties(_VisShape, m_dr, "datarow")
            End If

            If blnSilent = False Then
                MsgBox("DataRowsUpated = " & intRowsAffected)
            End If

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

        Return intRowsAffected

    End Function

    '
    '
    '
    Public Sub initDataSetAndTable()

        Try

            ' make sure the root stuff is there
            If m_ds Is Nothing Then
                m_ds = New DataSet
            Else
                m_ds = Nothing
                m_ds = New DataSet
            End If
            m_ds.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema

            If m_dt Is Nothing Then
                m_dt = New DataTable
            Else
                m_dt = Nothing
                m_dt = New DataTable
            End If

            If m_oc Is Nothing Then
                m_oc = New Collection(Of dc_Network)
            Else
                m_oc = Nothing
                m_oc = New Collection(Of dc_Network)
            End If

            If m_dc IsNot Nothing Then
                m_dc = Nothing
                m_dc = New dc_Network(strUserId)
            Else
                m_dc = New dc_Network(strUserId)
            End If


            CreateTableColumns(m_dt)
            m_dt.TableName = DC_RackTables.tblAttrNetwork.ToString
            m_ds.Tables.Add(m_dt)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try



    End Sub


#End Region

#Region " database interactions "

    '
    '
    '
    Public Sub dbSelectAttrNetworkByRowKey _
        (ByVal lngRowKey As Int32)



        Try


            initDataSetAndTable()

            ' Retrieve the initial data
            Dim cmd As DbCommand = m_db.GetStoredProcCommand("selectAttrNetworkByRowKey")
            m_db.AddInParameter(cmd, "@RowKey", DbType.Int32, lngRowKey)
            m_db.LoadDataSet(cmd, m_ds, DC_RackTables.tblAttrNetwork.ToString)
            m_dt = m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString)


        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch Ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(Ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Public Sub dbSelectAllNetworkData()


        Try

            If m_dc IsNot Nothing Then
                m_dc = Nothing
                m_dc = New dc_Network
            Else
                m_dc = New dc_Network
            End If

            initDataSetAndTable()

            ' Retrieve the initial data
            Dim cmd As DbCommand = m_db.GetStoredProcCommand(readAll)
            m_db.LoadDataSet(cmd, m_ds, DC_RackTables.tblAttrNetwork.ToString)

            m_dt = m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString)


        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Public Sub dbSelectAttrNetworkByCompKey(ByVal intCompKey As Int32)

        Try

            initDataSetAndTable()

            ' Retrieve the initial data
            Dim cmd As DbCommand = m_db.GetStoredProcCommand("selectAttrNetworkByCompKey")
            m_db.AddInParameter(cmd, "@compKey", DbType.Int32, intCompKey)
            m_db.LoadDataSet(cmd, m_ds, DC_RackTables.tblAttrNetwork.ToString)
            m_dt = m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString)


        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub


    '
    '
    '
    Public Sub dbSelectAttrNetworkByPortKey(ByVal intPortKey As Int32)

        Try

            initDataSetAndTable()

            ' Retrieve the initial data
            Dim cmd As DbCommand = m_db.GetStoredProcCommand("selectAttrNetworkByPortKey")
            m_db.AddInParameter(cmd, "@attrnetPortKey", DbType.Int32, intPortKey)
            m_db.LoadDataSet(cmd, m_ds, DC_RackTables.tblAttrNetwork.ToString)
            m_dt = m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString)


        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub


    '
    ' we use this one to chase a collection of ports, usually for the connection data class
    '
    Public Sub dbSelectAttrNetworkByPortKeyCollection _
        (ByVal colPortKeys As Collection)

        Dim dtTemp As DataTable = New DataTable
        Dim dtTempIn As DataTable = New DataTable
        Dim drTemp As DataRow
        Dim intPortKey As Int32


        Try

            ' use the collection of portkeys to create a custom portkey table
            For intCt = 1 To colPortKeys.Count
                If dtTempIn Is Nothing Then
                    dtTempIn = New DataTable
                Else
                    dtTempIn = Nothing
                    dtTempIn = New DataTable
                End If
                intPortKey = colPortKeys.Item(intCt)
                dbSelectAttrNetworkByPortKey(intPortKey)
                dtTempIn = m_dt.Copy
                If intCt = 1 Then
                    dtTemp = dtTempIn.Copy
                Else
                    For Each drTemp In dtTempIn.Rows
                        With drTemp
                            dtTemp.ImportRow(drTemp)
                        End With
                    Next
                End If
            Next intCt ' port key


            ' clean the data caches again
            initDataSetAndTable()

            dtTemp.TableName = DC_RackTables.tblAttrPortData.ToString
            m_dt = dtTemp.Copy
            If m_ds.Tables(myEnum.ToString) IsNot Nothing Then
                m_ds.Tables(myEnum.ToString).Clear()
                For Each drTemp In dtTemp.Rows
                    m_ds.Tables(myEnum.ToString).ImportRow(drTemp)
                Next
            Else
                m_ds.Tables.Add(dtTemp.Copy)
            End If



        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Public Sub dbSelectAttrNetworkByUrriKeys _
                (ByVal colURRIKeys As Collection(Of clsDC_RackData.rackURRI))

        initDataSetAndTable()


        Dim dtInput As DataTable = New DataTable
        Dim dtOutput As DataTable = New DataTable
        Dim drTemp As DataRow
        Dim lngRackKey As Int32
        Dim colRacks As Collection = New Collection
        Dim rckUrri As clsDC_RackData.rackURRI

        For Each rckUrri In colURRIKeys
            colRacks.Add(rckUrri.rckKey)
        Next rckUrri

        Try

            For intX = 1 To colRacks.Count
                lngRackKey = colRacks(intX)
                If Not (dtInput Is Nothing) Then
                    dtInput = Nothing
                    dtInput = New DataTable
                Else
                    dtInput = New DataTable
                End If
                dtInput = GetAttrNetworkByRack(lngRackKey)
                With dtInput
                    If intX = 1 Then
                        dtOutput = Nothing
                        dtOutput = New DataTable
                        dtOutput = dtInput.Copy
                    Else
                        For Each drTemp In .Rows
                            dtOutput.ImportRow(drTemp)
                        Next
                    End If
                End With
            Next intX

            dtOutput.TableName = DC_RackTables.tblAttrNetwork.ToString
            m_dt.TableName = DC_RackTables.tblAttrNetwork.ToString

            For Each drTemp In dtOutput.Rows
                m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString).ImportRow(drTemp)
            Next

            m_dt = m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch Ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(Ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Public Function GetAttrNetworkByRack _
                (ByVal lngRackKey As Int32) _
                As DataTable

        Dim m_dt1 As DataTable = New DataTable
        Dim dtReturn As DataTable = New DataTable
        Dim m_ds1 As DataSet = New DataSet

        Try

            Dim cmd1 As DbCommand
            cmd1 = m_db.GetStoredProcCommand("selectAttrNetworkByRack")
            m_db.AddInParameter(cmd1, "@compKey", DbType.Int32, lngRackKey)
            m_db.LoadDataSet(cmd1, m_ds1, "temp")
            m_dt1 = m_ds1.Tables("temp")

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
            m_dt1 = Nothing
        End Try

        GetAttrNetworkByRack = m_dt1

    End Function


    '
    '
    '
    Public Sub dbDeleteAttrNetworkByCompKey(ByVal intCompKey As Int32)


        If intCompKey = -1 Then Exit Sub

        Try

            Dim cmd As DbCommand = m_db.GetStoredProcCommand("deleteAttrNetworkByCompKey")
            m_db.AddInParameter(cmd, "@compKey", DbType.Int32, intCompKey)

            Dim affectedRows As Int16 = m_db.ExecuteNonQuery(cmd)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


    End Sub

    '
    '
    '
    Public Sub dbDeleteAttrNetworkByPortKey(ByVal intPortKey As Int32)


        If intPortKey = -1 Then Exit Sub

        Try

            Dim cmd As DbCommand = m_db.GetStoredProcCommand("deleteAttrNetworkByPortKey")
            m_db.AddInParameter(cmd, "@portKey", DbType.Int32, intPortKey)

            Dim affectedRows As Int16 = m_db.ExecuteNonQuery(cmd)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


    End Sub

    '
    '
    '
    Public Sub dbUpdateComponentNetworkStatus(ByVal intCompKey As Int32, _
                                          ByVal intStatus As dc_Network.netStatus)


        If intCompKey = -1 Then Exit Sub

        Try

            Dim cmd As DbCommand = m_db.GetStoredProcCommand("updateComponentNetworkStatus")
            m_db.AddInParameter(cmd, "@compKey", DbType.Int32, intCompKey)
            m_db.AddInParameter(cmd, "@compStatus", DbType.Int16, intStatus)

            Dim affectedRows As Int16 = m_db.ExecuteNonQuery(cmd)

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


    End Sub




#End Region

#Region " Visio Interaction "

    '
    ' a simple set of network properties
    '
    Public Sub addTestNetworkProperties()

        With m_dc
            .attrnetCompKey = -1
            .attrnetDomainName = "testDomName"
            .attrnetNetworkName = "testDevName"
            .attrnetIpAddress = "127.0.0.1"
            .attrnetSubnetMask = "255.255.255.0"
            .attrnetMacAddress = "1234567890ab"
            .attrnetWWNID = "00:00:00:00:00:00:00:00"
            .attrnetStatus = dc_Network.netStatus.netActive
        End With

    End Sub


    '
    '
    '
    Public Sub UpdateNetworkProperties _
                (ByRef visShape As Microsoft.Office.Interop.Visio.Shape, _
                 ByVal drNetwork As System.Data.DataRow, _
                 ByVal strSource As String)

        Try

            If Not (drNetwork Is Nothing) Then
                strSource = "datarow"
            End If

            ' make sure everyone is on the same page
            _clsVisio.drawingPage = drawingPage

            Select Case strSource
                Case "datarow"

                    moveDataRowToProperties(drNetwork)

                Case "addattr"
                    ' use existing properties

                Case Else

                    addTestNetworkProperties()

            End Select

            With m_dc
                _clsVisio.ForceShapeData(visShape, "attrnetCompKey", .attrnetCompKey, "attrNetwork")
                _clsVisio.ForceShapeData(visShape, "attrnetDomainName", .attrnetDomainName, "attrNetwork")
                _clsVisio.ForceShapeData(visShape, "attrnetNetworkName", .attrnetNetworkName, "attrNetwork")
                _clsVisio.ForceShapeData(visShape, "attrnetIpAddress", .attrnetIpAddress, "attrNetwork")
                _clsVisio.ForceShapeData(visShape, "attrnetSubnetMask", .attrnetSubnetMask, "attrNetwork")
                _clsVisio.ForceShapeData(visShape, "attrnetMacAddress", .attrnetMacAddress, "attrNetwork")
                _clsVisio.ForceShapeData(visShape, "attrnetWWNID", .attrnetWWNID, "attrNetwork")

                MakeNetworkStatusAware(visShape, drNetwork)

                Dim intStatus As netStatus = .attrnetStatus
                _clsVisio.ForceShapeData(visShape, "attrnetStatus", intStatus.ToString, "attrNetwork")
                visShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLayerMem, VisCellIndices.visLayerMember).FormulaForceU = """"""
                _clsVisio.addShapeToLayer(drawingPage, visShape, intStatus.ToString, 0)



            End With

        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    ' this is where we ensure that the outline color reflects the layer selected
    ' we end up forcing the line style and color just so the object is aware......
    '
    Public Sub MakeNetworkStatusAware _
                (ByRef visShape As Microsoft.Office.Interop.Visio.Shape, _
                 ByVal drNetwork As System.Data.DataRow)

        Dim shpCell As Microsoft.Office.Interop.Visio.Cell
        Dim visEmbShape As Microsoft.Office.Interop.Visio.Shape

        Try

            If Not (drNetwork Is Nothing) Then
                m_dc.attrnetStatus = drNetwork.Field(Of Integer)("attrnetStatus")
            Else
                ' when we do the example we do not pass in a datarecord
                m_dc.attrnetStatus = dc_Network.netStatus.netUndefined
            End If

            If visShape.CellExists("prop.attrnetStatus", False) = False Then
                _clsVisio.ForceShapeData(visShape, "attrnetStatus", m_dc.attrnetStatus, "attrNetwork")
            End If

            shpCell = visShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLine, VisCellIndices.visLineColor)
            shpCell.Formula = VisDefaultColors.visBlack
            shpCell = visShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLine, VisCellIndices.visLinePattern)
            shpCell.Formula = VisCellVals.visSolid
            If visShape.Type = VisShapeTypes.visTypeGroup Then
                'Debug.Print "it is a group"
                visEmbShape = visShape.Shapes(1)
                'Debug.Print "instantiate an embedded shape"
                shpCell = visEmbShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLine, VisCellIndices.visLineColor)
                shpCell.Formula = VisDefaultColors.visBlack
                shpCell = visEmbShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLine, VisCellIndices.visLinePattern)
                shpCell.Formula = VisCellVals.visSolid
                ' how wide to make the line
                shpCell = visEmbShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLine, VisCellIndices.visLineWeight)
                shpCell.Formula = 0.01
            End If

            visShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowLayerMem, VisCellIndices.visLayerMember).FormulaForceU = """"""
            _clsVisio.addShapeToLayer(drawingPage, visShape, m_dc.attrnetStatus, False)


        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try
    End Sub

    Private Const constNetPinX As String = "6.5 in"
    Private Const constNetPinY As String = "9.875 in"
    Private Const constNetAlign As VisListAlignment = VisListAlignment.visListAlignLeftOrTop
    Private Const constNetDir As VisListDirection = VisListDirection.visListDirTopToBottom
    Private Const constNetHeader As String = "Network"
    Private Const constNetMaster As String = "Container 4"

    ' wireframe stencil for list (vertical w/header on side and horizontal) toolbar 
    Const stencilWFToolbar As String = "wftlbr_u.vss"
    Const masterDropDown As String = "Drop-down menu"
    Const masterDropDownItem As String = "Menu item"




    '
    ' finds all of the ports for a given component and puts them into a container
    ' this build container needed to be extended because when pulling ports for a component such as a 
    ' network patch panel we could end up with 60+ items
    '
    Public Function buildNetworkDataContainer _
                        (ByVal strSource As String, _
                         ByVal intKey As Int32, _
                         ByVal _clsData As clsDC_RackData, _
                         Optional ByVal blnUseItemSurrogate As Boolean = False) _
                        As Microsoft.Office.Interop.Visio.Shape

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Dim strStencil As String = ""
        Dim strMaster As String = ""
        Dim strDGMaster As String = ""
        Dim visDG As Microsoft.Office.Interop.Visio.Master = Nothing
        Dim intLabelFont As Integer
        Dim intValueFont As Integer
        Dim dblCalloutWidth As Double

        ' just to make sure
        _clsVisio.drawingPage = drawingPage
        drawingDocument = drawingPage.Document

        Try


            Dim colInput As Collection = New Collection
            Dim drTemp As System.Data.DataRow = Nothing
            Dim netQuery As System.Data.EnumerableRowCollection(Of System.Data.DataRow)


            If strSource = "comp" Then

                ' find our component record
                netQuery = From compnet In _clsData.m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString).AsEnumerable() _
                           Where compnet!attrnetcompkey = intKey
                          Select compnet

            Else

                ' find our port record
                netQuery = From portnet In _clsData.m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString).AsEnumerable() _
                           Where portnet!attrnetportkey = intKey
                          Select portnet

            End If


            If netQuery.Count = 0 Then Return shpContainer

            ' there is no guarantee that network data has been supplied for either components or ports
            If 0 < netQuery.Count Then
                For Each n In netQuery
                    colInput.Add("attrnetKey_" & n.Item("attrnetKey").ToString)
                    'System.Diagnostics.Debug.WriteLine(n.Item("attrnetNetworkName").ToString)
                    'System.Diagnostics.Debug.WriteLine(n.Item("attrnetKey").ToString)
                    drTemp = n
                Next n
            Else
                Return Nothing
            End If


            ' create a list control
            Dim listControl As Microsoft.Office.Interop.Visio.Shape = Nothing
            ' pass in the created collection and return a populated list control
            Dim colMembers As Collection = New Collection

            If blnUseItemSurrogate = vbFalse Then

                colMembers = _clsVisio.dropDropDownBoxItems(colInput, masterDropDownItem, stencilWFToolbar, "1.5in", ".25in", vbTrue)

            Else


                Dim dgmasterQuery = From datagraphic In _clsData.m_ds.Tables(DC_RackTables.tblDGMasters.ToString).AsEnumerable() _
                                    Where datagraphic!dgmTable = DC_RackTables.tblAttrNetwork.ToString _
                                    Select datagraphic

                ' should only be one..
                For Each m In dgmasterQuery
                    If LCase(m!dgmTable) = LCase(DC_RackTables.tblAttrNetwork.ToString) Then
                        strStencil = m!dgmSurrogateStencil
                        strStencil = _CustomStencilPath & strStencil
                        strMaster = m!dgmSurrogateMaster
                        intLabelFont = CInt(m!dgmFontLabel)
                        intValueFont = CInt(m!dgmFontValue)
                        dblCalloutWidth = CDbl(m!dgmCalloutWidth)
                        strDGMaster = m!dgmMaster
                        Exit For
                    End If
                Next

                ' pass in the created collection and return a populated list control
                colMembers = _clsVisio.dropDropDownBoxItems(colInput, strMaster, strStencil, "1.5", "1.0", vbTrue)


            End If


            Dim visShape As Microsoft.Office.Interop.Visio.Shape = Nothing
            Dim visCell As Microsoft.Office.Interop.Visio.Cell = Nothing
            Dim strName As String = ""
            Dim strKey As String = ""
            For Each shapeId In colMembers
                ' get the shape
                visShape = drawingPage.Shapes.ItemFromID(shapeId)
                If visShape.CellExists("user.attrkey", False) = True Then
                    strName = visShape.Cells("user.attrkey").ResultStr("")
                Else
                    strName = ""
                    GoTo NextShape
                End If

                ' clear any shape data properties
                _clsVisio.deleteShapeData(visShape)

                ' set it semi-transparent
                Dim strTrans As String = "50%"
                ' first the fill properties
                _clsVisio.recurseApplyCellFormula(visShape, VisSectionIndices.visSectionObject, VisRowIndices.visRowFill, VisCellIndices.visFillForegndTrans, strTrans)
                _clsVisio.recurseApplyCellFormula(visShape, VisSectionIndices.visSectionObject, VisRowIndices.visRowFill, VisCellIndices.visFillBkgndTrans, strTrans)
                ' then the line properties
                _clsVisio.recurseApplyCellFormula(visShape, VisSectionIndices.visSectionObject, VisRowIndices.visRowLine, VisCellIndices.visLineColorTrans, strTrans)
                ' prep it for applying the datagraphics by applying the data from the dgmasters table
                _clsVisio.addDataGraphicUserFieldsToShape _
                        (visShape, _
                        intValueFont.ToString, _
                        intLabelFont.ToString, _
                        dblCalloutWidth.ToString)

                'Check that the requested Data Graphic Master exits
                For Each visMaster In drawingDocument.Masters
                    If visMaster.Type = VisMasterTypes.visTypeDataGraphic Then
                        If visMaster.Name = strDGMaster Then
                            visDG = visMaster
                            Exit For
                        End If
                    End If
                Next

                ' go read the current records
                For Each n In netQuery
                    strKey = "attrnetKey_" & n.Item("attrnetKey").ToString
                    If strKey = strName Then

                        UpdateNetworkProperties(visShape, n, "datarow")
                        visShape.Text = n.Item("attrnetNetworkName").ToString

                        ' allow the legend to keep track of the shapes
                        _clsVisio.ForceUserProperty(visShape, "visLegendShape", "2.0")

                        ' move the name to comment field so we get mouse over
                        If visShape.CellsSRCExists(VisSectionIndices.visSectionObject, VisRowIndices.visRowMisc, VisCellIndices.visComment, False) = True Then
                            visCell = visShape.CellsSRC(VisSectionIndices.visSectionObject, VisRowIndices.visRowMisc, VisCellIndices.visComment)
                            _clsVisio.SetCellValueToString(visCell, strName)
                        End If

                        ' if it is using a surrogate then attempt to apply the datagraphic
                        If blnUseItemSurrogate = True Then

                            'Apply the Data Graphic to the Shape
                            visShape.DataGraphic = visDG

                            ' unlock the groups so we can change the font sizes
                            _clsVisio.recurseApplyCellFormula(visShape, VisSectionIndices.visSectionObject, VisRowIndices.visRowLock, VisCellIndices.visLockGroup, "0")

                            If visShape.CellExists("user.dbIntLabelFont", False) = True Then

                                ' get the loaded values 
                                intLabelFont = CInt(visShape.Cells("user.dbintlabelfont").ResultIU)
                                intValueFont = CInt(visShape.Cells("user.dbintvaluefont").ResultIU)
                                dblCalloutWidth = CDbl(visShape.Cells("user.dbdblcallout").ResultIU)

                                ' set the callout width = 85% of the surrogate shapes width (as a formula) so that it fits inside the shape
                                Dim strId As String = visShape.NameID & "!Width*.85"
                                strId = "Guard(" & strId & ")"

                                _clsVisio.recurseApplyCustomFormula(visShape, "prop.msvcalloutproplabelsize", intLabelFont.ToString & " pt")
                                _clsVisio.recurseApplyCustomFormula(visShape, "prop.msvcalloutpropvaluesize", intValueFont.ToString & " pt")
                                _clsVisio.recurseApplyCustomFormula(visShape, "prop.msvcalloutpropwidth", strId)

                            End If

                        End If

                        Exit For
                    End If
                Next n
NextShape:

            Next shapeId

            shpContainer = _clsVisio.addContainerToPage(constNetMaster, "", "")

            ' put the shapes into the list
            listControl = _clsVisio.loadListControl(colMembers, constNetAlign, constNetDir)
            'listControl.Name = "listNetwork"
            'listControl.NameU = "listNetwork"

            ' add the list control to the container
            _clsVisio.AddShapeToContainer(shpContainer, listControl)

            shpContainer.Cells("pinx").Formula = constNetPinX
            shpContainer.Cells("piny").Formula = constNetPinY


        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


        System.Windows.Forms.Application.DoEvents()
        Return shpContainer

    End Function








#End Region

#Region " Constructor "

    '
    '
    '
    Public Sub New(ByVal visApp As Microsoft.Office.Interop.Visio.Application, _
                   ByVal visDoc As Microsoft.Office.Interop.Visio.Document)
        Try



            m_db = DatabaseFactory.CreateDatabase()

            strUserId = Environment.UserDomainName & "/" & Environment.UserName

            '
            ' init an object class so that the default constants are available
            ' to the table definitions
            '


            initDataSetAndTable()


            _clsVisio = New visRackComponentAttributes.clsVisioSupport
            _clsVisio.drawingApplication = visApp
            _clsVisio.drawingDocument = visDoc


            m_updateCommand = Nothing
            m_insertCommand = Nothing
            m_deleteCommand = Nothing

            buildInsertAttrNetworkCommand()
            buildDeleteAttrNetworkCommand()
            buildUpdateAttrNetworkCommand()


        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

#End Region


End Class
